package com.sc.nft.constant;

import com.baomidou.mybatisplus.extension.plugins.inner.DynamicTableNameInnerInterceptor;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 分区表名常量池
 *
 * @author zlikun
 * @since 2024/06/14
 */
public interface TableNameConstants {

    String COLLECTION_CHAIN_INIT_DETAILS_LOG = "sc_collection_chain_init_details_log";
    String EXPENDITURE_RECORD = "sc_expenditure_record";
    String USER_WALLET_DETAIL = "sc_user_wallet_detail";

    /**
     * @return 全部分区表
     * @see DynamicTableNameInnerInterceptor
     */
    static List<String> allTableNames() {
        // DynamicTableNameInnerInterceptor 处理时未处理 `` 包裹表名、表名大小写等情况，这里做容错处理
        return Stream.of(
                        COLLECTION_CHAIN_INIT_DETAILS_LOG,
                        EXPENDITURE_RECORD,
                        USER_WALLET_DETAIL)
                .flatMap(table -> Stream.of(table, "`" + table + "`"))
                .flatMap(table -> Stream.of(table.toUpperCase(), table.toLowerCase()))
                .collect(Collectors.toList());
    }

}
